package com.lianxian.xindong.login.mvp.ui.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.hxb.library.base.BaseActivity;
import com.hxb.library.di.component.AppComponent;
import com.hxb.library.utils.HxbUtils;
import com.lianxian.xindong.commonsdk.utils.ImmersionBarUtil;
import com.lianxian.xindong.login.R;
import com.lianxian.xindong.login.R2;
import com.lianxian.xindong.login.di.component.DaggerOtherStepThreeComponent;
import com.lianxian.xindong.login.mvp.contract.OtherStepThreeContract;
import com.lianxian.xindong.login.mvp.model.entity.TagHobbyBean;
import com.lianxian.xindong.login.mvp.presenter.OtherStepThreePresenter;
import com.lianxian.xindong.login.mvp.ui.adapter.TagHobbyAdapter;
import com.zhy.view.flowlayout.FlowLayout;
import com.zhy.view.flowlayout.TagFlowLayout;

import java.util.List;

import javax.inject.Inject;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

import static com.hxb.library.utils.Preconditions.checkNotNull;


/**
 * @作者：hexingbo
 * @时间：07/04/2023
 * @描述：
 */
public class OtherStepThreeActivity extends BaseActivity<OtherStepThreePresenter> implements OtherStepThreeContract.View {

    @Inject
    TagHobbyAdapter mAdapter;
    @Inject
    List<TagHobbyBean> mDataList;

    @BindView(R2.id.fl_tag_hobby)
    TagFlowLayout flTagHobby;
    @BindView(R2.id.btn_submit)
    Button btnSubmit;

    @Override
    public void setupActivityComponent(@NonNull AppComponent appComponent) {
        DaggerOtherStepThreeComponent //如找不到该类,请编译一下项目
                .builder()
                .appComponent(appComponent)
                .view(this)
                .build()
                .inject(this);
    }

    @Override
    public int initView(@Nullable Bundle savedInstanceState) {
        return R.layout.activity_other_step_three; //如果你不需要框架帮你设置 setContentView(id) 需要自行设置,请返回 0
    }

    @Override
    public void initData(@Nullable Bundle savedInstanceState) {
        ImmersionBarUtil.setImmersionBar(this, true);
        btnSubmit.setText(R.string.login_finish);
        flTagHobby.setAdapter(mAdapter);
        flTagHobby.setOnTagClickListener(new TagFlowLayout.OnTagClickListener() {
            @Override
            public boolean onTagClick(View view, int position, FlowLayout parent) {

                return false;
            }
        });

        mPresenter.getHobbyData();
    }

    @Override
    public void showLoading() {

    }

    @Override
    public void hideLoading() {

    }

    @Override
    public void showMessage(@NonNull String message) {
        checkNotNull(message);
        HxbUtils.snackbarText(message);
    }

    @Override
    public void launchActivity(@NonNull Intent intent) {
        checkNotNull(intent);
        HxbUtils.startActivity(intent);
    }

    @Override
    public void killMyself() {
        finish();
    }

    @Override
    public Context getContext() {
        return this;
    }

    @OnClick(R2.id.btn_submit)
    public void onViewClicked() {
        mPresenter.submitOtherStepInfo();
    }
}
